package org.fireflow2.designer.eclipse.wizards;

import org.eclipse.core.runtime.Path;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.dialogs.WizardNewFileCreationPage;
import org.fireflow.pdl.fpdl20.misc.FpdlConstants;

public class NewWorkflowProcessWizardPage extends WizardNewFileCreationPage {

	public NewWorkflowProcessWizardPage(String pageId, IStructuredSelection selection) {
		super(pageId, selection);
	}
	
	@Override
	protected boolean validatePage() {		
		if (super.validatePage()) {
			String fileName = this.getFileName();

			if (fileName==null || fileName.trim().equals("")) return false;
			String extension = new Path(getFileName()).getFileExtension();
			if (extension == null || fileName.trim().toUpperCase().endsWith(FpdlConstants.PROCESS_FILE_SUFFIX.toUpperCase())) {
				return true;
			}
			return false;
		}
		return false;
	}

}
